#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#define int long long 
using namespace std;
const int N = 5010;
int a[N];
void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	char la = s[0];
	int ans = 0;
	int sum = 1;
	if (n == 1)
	{
		cout << 1 << endl;
		return;
	}
	for (int i = 1; i < n; i++)
	{
		cout << sum << '-' << endl;
		if (s[i] != la)
		{
			if (s[i] == '+')
			{
				if (sum >= 0)
				{
					ans += abs(sum);
					//cout << i + 1 << ' ' << abs(sum) << endl;
					sum = 1;
				}
				else
				{
					sum++;
				}
			}
			else
			{
				if (sum <= 0)
				{
					ans += abs(sum);
					//cout << i + 1 << ' ' << abs(sum) << endl;
					sum = -1;
				}
				else
				{
					sum--;
				}
			}
			la = s[i];
			continue;
		}
		if (s[i] == '+')
			sum++;
		else sum--;
	}
	ans += abs(sum);
	cout << ans << endl;
}

signed main()
{
	int t = 1;
	cin >> t;
	while (t--)
		solve();
	return 0;
}